/*----------------------------------------------------------------------------
 * Tab
 * ---------------------------------------------------------------------------
 * Date      : 2011-02-08
 * Author    : naiyumie
 * ---------------------------------------------------------------------------
 * USAGE
 * ---------------------------------------------------------------------------
 * $(selector).Tab();
 * ---------------------------------------------------------------------------
 * EXAMPLE
 * ---------------------------------------------------------------------------
 *
 *----------------------------------------------------------------------------
 */
$.fn.Tab	= function ()
{
	var element	= $(this);

	$(element).each(function()
	{
		var obj	= $(this);

		$(this).children('div.tab-wrap').each(function(i)
		{
			if (i>0) { $(this).hide(); }

			$(this).find('ul.tab-header').children('li').find('a:first').each(function()
			{
				$(this).click(function()
				{
					try
					{
						var list	= $(obj).find('div' + $(this).attr('href'));
						var target	= $(this).attr('href');

						if ($(list).length>0)
						{
							$(obj).children('div.tab-wrap').hide();
							$(list).show();

							$(list).children('ul.tab-header').find('a').each(function()
							{
								if ($(this).attr('href')==target) { $(this).focus(); }
							});
						}

						return false;
					}
					catch (e) {}
				});
			});
		});
	});
};